<template>
  <div>
    <el-dialog v-bind="$attrs" v-on="$listeners" @open="onOpen" @close="onClose" title="Dialog Title">
      <el-row :gutter="14">
        <el-form ref="elForm" :model="formData" :rules="rules" size="small" label-width="120px">
          <el-col :span="24">
            <el-row>
              <el-col :span="24">
                <el-form-item label="标题" prop="title">
                  <el-input v-model="formData.title" placeholder="请输入标题" clearable :style="{width: '100%'}">
                  </el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-col>
          <el-col :span="24">
            <el-row>
              <el-col :span="12">
                <el-form-item label="附件(去年)" prop="fjidone" required>
                  <el-upload ref="fjidone" :file-list="fjidonefileList" :action="fjidoneAction"
                    :before-upload="fjidoneBeforeUpload">
                    <el-button size="small" type="primary" icon="el-icon-upload">点击上传</el-button>
                  </el-upload>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="附件(去年)" prop="fjidtwo" required>
                  <el-upload ref="fjidtwo" :file-list="fjidtwofileList" :action="fjidtwoAction"
                    :before-upload="fjidtwoBeforeUpload">
                    <el-button size="small" type="primary" icon="el-icon-upload">点击上传</el-button>
                  </el-upload>
                </el-form-item>
              </el-col>
            </el-row>
          </el-col>
          <el-col :span="24">
            <el-row type="flex" justify="center" align="middle">
              <el-col :span="3">
                <el-form-item label="按钮" prop="field109">
                  <el-button type="primary" size="medium"></el-button>
                </el-form-item>
              </el-col>
              <el-col :span="4">
                <el-form-item label="按钮" prop="field111">
                  <el-button type="primary" size="medium"></el-button>
                </el-form-item>
              </el-col>
            </el-row>
          </el-col>
        </el-form>
      </el-row>
      <div slot="footer">
        <el-button @click="close">取消</el-button>
        <el-button type="primary" @click="handleConfirm">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
export default {
  inheritAttrs: false,
  components: {},
  props: [],
  data() {
    return {
      formData: {
        title: undefined,
        fjidone: null,
        fjidtwo: null,
        field109: undefined,
        field111: undefined,
      },
      rules: {
        title: [{
          required: true,
          message: '请输入标题',
          trigger: 'blur'
        }],
      },
      fjidoneAction: '/dev-api/system/oss/upload',
      fjidonefileList: [],
      fjidtwoAction: '/dev-api/system/oss/upload',
      fjidtwofileList: [],
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    onOpen() {},
    onClose() {
      this.$refs['elForm'].resetFields()
    },
    close() {
      this.$emit('update:visible', false)
    },
    handleConfirm() {
      this.$refs['elForm'].validate(valid => {
        if (!valid) return
        this.close()
      })
    },
    fjidoneBeforeUpload(file) {
      let isRightSize = file.size / 1024 / 1024 < 2
      if (!isRightSize) {
        this.$message.error('文件大小超过 2MB')
      }
      return isRightSize
    },
    fjidtwoBeforeUpload(file) {
      let isRightSize = file.size / 1024 / 1024 < 2
      if (!isRightSize) {
        this.$message.error('文件大小超过 2MB')
      }
      return isRightSize
    },
  }
}

</script>
<style>
.el-upload__tip {
  line-height: 1.2;
}

</style>
